{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 11.12 \u7406\u89e3\u4e8b\u4ef6\u9a71\u52a8\u7684IO\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u95ee\u9898\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4f60\u5e94\u8be5\u5df2\u7ecf\u542c\u8fc7\u57fa\u4e8e\u4e8b\u4ef6\u9a71\u52a8\u6216\u5f02\u6b65I/O\u7684\u5305\uff0c\u4f46\u662f\u4f60\u8fd8\u4e0d\u80fd\u5b8c\u5168\u7406\u89e3\u5b83\u7684\u5e95\u5c42\u5230\u5e95\u662f\u600e\u6837\u5de5\u4f5c\u7684\uff0c\n\u6216\u8005\u662f\u5982\u679c\u4f7f\u7528\u5b83\u7684\u8bdd\u4f1a\u5bf9\u4f60\u7684\u7a0b\u5e8f\u4ea7\u751f\u4ec0\u4e48\u5f71\u54cd\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u89e3\u51b3\u65b9\u6848\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4e8b\u4ef6\u9a71\u52a8I/O\u672c\u8d28\u4e0a\u6765\u8bb2\u5c31\u662f\u5c06\u57fa\u672cI/O\u64cd\u4f5c\uff08\u6bd4\u5982\u8bfb\u548c\u5199\uff09\u8f6c\u5316\u4e3a\u4f60\u7a0b\u5e8f\u9700\u8981\u5904\u7406\u7684\u4e8b\u4ef6\u3002\n\u4f8b\u5982\uff0c\u5f53\u6570\u636e\u5728\u67d0\u4e2asocket\u4e0a\u88ab\u63a5\u53d7\u540e\uff0c\u5b83\u4f1a\u8f6c\u6362\u6210\u4e00\u4e2a receive \u4e8b\u4ef6\uff0c\u7136\u540e\u88ab\u4f60\u5b9a\u4e49\u7684\u56de\u8c03\u65b9\u6cd5\u6216\u51fd\u6570\u6765\u5904\u7406\u3002\n\u4f5c\u4e3a\u4e00\u4e2a\u53ef\u80fd\u7684\u8d77\u59cb\u70b9\uff0c\u4e00\u4e2a\u4e8b\u4ef6\u9a71\u52a8\u7684\u6846\u67b6\u53ef\u80fd\u4f1a\u4ee5\u4e00\u4e2a\u5b9e\u73b0\u4e86\u4e00\u7cfb\u5217\u57fa\u672c\u4e8b\u4ef6\u5904\u7406\u5668\u65b9\u6cd5\u7684\u57fa\u7c7b\u5f00\u59cb\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "class EventHandler:\n    def fileno(self):\n        'Return the associated file descriptor'\n        raise NotImplemented('must implement')\n\n    def wants_to_receive(self):\n        'Return True if receiving is allowed'\n        return False\n\n    def handle_receive(self):\n        'Perform the receive operation'\n        pass\n\n    def wants_to_send(self):\n        'Return True if sending is requested'\n        return False\n\n    def handle_send(self):\n        'Send outgoing data'\n        pass"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u8fd9\u4e2a\u7c7b\u7684\u5b9e\u4f8b\u4f5c\u4e3a\u63d2\u4ef6\u88ab\u653e\u5165\u7c7b\u4f3c\u4e0b\u9762\u8fd9\u6837\u7684\u4e8b\u4ef6\u5faa\u73af\u4e2d\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import select\n\ndef event_loop(handlers):\n    while True:\n        wants_recv = [h for h in handlers if h.wants_to_receive()]\n        wants_send = [h for h in handlers if h.wants_to_send()]\n        can_recv, can_send, _ = select.select(wants_recv, wants_send, [])\n        for h in can_recv:\n            h.handle_receive()\n        for h in can_send:\n            h.handle_send()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4e8b\u4ef6\u5faa\u73af\u7684\u5173\u952e\u90e8\u5206\u662f select() \u8c03\u7528\uff0c\u5b83\u4f1a\u4e0d\u65ad\u8f6e\u8be2\u6587\u4ef6\u63cf\u8ff0\u7b26\u4ece\u800c\u6fc0\u6d3b\u5b83\u3002\n\u5728\u8c03\u7528 select() \u4e4b\u524d\uff0c\u4e8b\u4ef6\u5faa\u73af\u4f1a\u8be2\u95ee\u6240\u6709\u7684\u5904\u7406\u5668\u6765\u51b3\u5b9a\u54ea\u4e00\u4e2a\u60f3\u63a5\u53d7\u6216\u53d1\u751f\u3002\n\u7136\u540e\u5b83\u5c06\u7ed3\u679c\u5217\u8868\u63d0\u4f9b\u7ed9 select() \u3002\u7136\u540e select() \u8fd4\u56de\u51c6\u5907\u63a5\u53d7\u6216\u53d1\u9001\u7684\u5bf9\u8c61\u7ec4\u6210\u7684\u5217\u8868\u3002\n\u7136\u540e\u76f8\u5e94\u7684 handle_receive() \u6216 handle_send() \u65b9\u6cd5\u88ab\u89e6\u53d1\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u7f16\u5199\u5e94\u7528\u7a0b\u5e8f\u7684\u65f6\u5019\uff0cEventHandler \u7684\u5b9e\u4f8b\u4f1a\u88ab\u521b\u5efa\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u662f\u4e24\u4e2a\u7b80\u5355\u7684\u57fa\u4e8eUDP\u7f51\u7edc\u670d\u52a1\u7684\u5904\u7406\u5668\u4f8b\u5b50\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import socket\nimport time\n\nclass UDPServer(EventHandler):\n    def __init__(self, address):\n        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n        self.sock.bind(address)\n\n    def fileno(self):\n        return self.sock.fileno()\n\n    def wants_to_receive(self):\n        return True\n\nclass UDPTimeServer(UDPServer):\n    def handle_receive(self):\n        msg, addr = self.sock.recvfrom(1)\n        self.sock.sendto(time.ctime().encode('ascii'), addr)\n\nclass UDPEchoServer(UDPServer):\n    def handle_receive(self):\n        msg, addr = self.sock.recvfrom(8192)\n        self.sock.sendto(msg, addr)\n\nif __name__ == '__main__':\n    handlers = [ UDPTimeServer(('',14000)), UDPEchoServer(('',15000))  ]\n    event_loop(handlers)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u6d4b\u8bd5\u8fd9\u6bb5\u4ee3\u7801\uff0c\u8bd5\u7740\u4ece\u53e6\u5916\u4e00\u4e2aPython\u89e3\u91ca\u5668\u8fde\u63a5\u5b83\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "from socket import *\ns = socket(AF_INET, SOCK_DGRAM)\ns.sendto(b'',('localhost',14000))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "s.recvfrom(128)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "s.sendto(b'Hello',('localhost',15000))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "s.recvfrom(128)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5b9e\u73b0\u4e00\u4e2aTCP\u670d\u52a1\u5668\u4f1a\u66f4\u52a0\u590d\u6742\u4e00\u70b9\uff0c\u56e0\u4e3a\u6bcf\u4e00\u4e2a\u5ba2\u6237\u7aef\u90fd\u8981\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684\u5904\u7406\u5668\u5bf9\u8c61\u3002\n\u4e0b\u9762\u662f\u4e00\u4e2aTCP\u5e94\u7b54\u5ba2\u6237\u7aef\u4f8b\u5b50\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "class TCPServer(EventHandler):\n    def __init__(self, address, client_handler, handler_list):\n        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)\n        self.sock.bind(address)\n        self.sock.listen(1)\n        self.client_handler = client_handler\n        self.handler_list = handler_list\n\n    def fileno(self):\n        return self.sock.fileno()\n\n    def wants_to_receive(self):\n        return True\n\n    def handle_receive(self):\n        client, addr = self.sock.accept()\n        # Add the client to the event loop's handler list\n        self.handler_list.append(self.client_handler(client, self.handler_list))\n\nclass TCPClient(EventHandler):\n    def __init__(self, sock, handler_list):\n        self.sock = sock\n        self.handler_list = handler_list\n        self.outgoing = bytearray()\n\n    def fileno(self):\n        return self.sock.fileno()\n\n    def close(self):\n        self.sock.close()\n        # Remove myself from the event loop's handler list\n        self.handler_list.remove(self)\n\n    def wants_to_send(self):\n        return True if self.outgoing else False\n\n    def handle_send(self):\n        nsent = self.sock.send(self.outgoing)\n        self.outgoing = self.outgoing[nsent:]\n\nclass TCPEchoClient(TCPClient):\n    def wants_to_receive(self):\n        return True\n\n    def handle_receive(self):\n        data = self.sock.recv(8192)\n        if not data:\n            self.close()\n        else:\n            self.outgoing.extend(data)\n\nif __name__ == '__main__':\n   handlers = []\n   handlers.append(TCPServer(('',16000), TCPEchoClient, handlers))\n   event_loop(handlers)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "TCP\u4f8b\u5b50\u7684\u5173\u952e\u70b9\u662f\u4ece\u5904\u7406\u5668\u4e2d\u5217\u8868\u589e\u52a0\u548c\u5220\u9664\u5ba2\u6237\u7aef\u7684\u64cd\u4f5c\u3002\n\u5bf9\u6bcf\u4e00\u4e2a\u8fde\u63a5\uff0c\u4e00\u4e2a\u65b0\u7684\u5904\u7406\u5668\u88ab\u521b\u5efa\u5e76\u52a0\u5230\u5217\u8868\u4e2d\u3002\u5f53\u8fde\u63a5\u88ab\u5173\u95ed\u540e\uff0c\u6bcf\u4e2a\u5ba2\u6237\u7aef\u8d1f\u8d23\u5c06\u5176\u4ece\u5217\u8868\u4e2d\u5220\u9664\u3002\n\u5982\u679c\u4f60\u8fd0\u884c\u7a0b\u5e8f\u5e76\u8bd5\u7740\u7528Telnet\u6216\u7c7b\u4f3c\u5de5\u5177\u8fde\u63a5\uff0c\u5b83\u4f1a\u5c06\u4f60\u53d1\u9001\u7684\u6d88\u606f\u56de\u663e\u7ed9\u4f60\u3002\u5e76\u4e14\u5b83\u80fd\u5f88\u8f7b\u677e\u7684\u5904\u7406\u591a\u5ba2\u6237\u7aef\u8fde\u63a5\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u8ba8\u8bba\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5b9e\u9645\u4e0a\u6240\u6709\u7684\u4e8b\u4ef6\u9a71\u52a8\u6846\u67b6\u539f\u7406\u8ddf\u4e0a\u9762\u7684\u4f8b\u5b50\u76f8\u5dee\u65e0\u51e0\u3002\u5b9e\u9645\u7684\u5b9e\u73b0\u7ec6\u8282\u548c\u8f6f\u4ef6\u67b6\u6784\u53ef\u80fd\u4e0d\u4e00\u6837\uff0c\n\u4f46\u662f\u5728\u6700\u6838\u5fc3\u7684\u90e8\u5206\uff0c\u90fd\u4f1a\u6709\u4e00\u4e2a\u8f6e\u8be2\u7684\u5faa\u73af\u6765\u68c0\u67e5\u6d3b\u52a8socket\uff0c\u5e76\u6267\u884c\u54cd\u5e94\u64cd\u4f5c\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4e8b\u4ef6\u9a71\u52a8I/O\u7684\u4e00\u4e2a\u53ef\u80fd\u597d\u5904\u662f\u5b83\u80fd\u5904\u7406\u975e\u5e38\u5927\u7684\u5e76\u53d1\u8fde\u63a5\uff0c\u800c\u4e0d\u9700\u8981\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b\u3002\n\u4e5f\u5c31\u662f\u8bf4\uff0cselect() \u8c03\u7528\uff08\u6216\u5176\u4ed6\u7b49\u6548\u7684\uff09\u80fd\u76d1\u542c\u5927\u91cf\u7684socket\u5e76\u54cd\u5e94\u5b83\u4eec\u4e2d\u4efb\u4f55\u4e00\u4e2a\u4ea7\u751f\u4e8b\u4ef6\u7684\u3002\n\u5728\u5faa\u73af\u4e2d\u4e00\u6b21\u5904\u7406\u4e00\u4e2a\u4e8b\u4ef6\uff0c\u5e76\u4e0d\u9700\u8981\u5176\u4ed6\u7684\u5e76\u53d1\u673a\u5236\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4e8b\u4ef6\u9a71\u52a8I/O\u7684\u7f3a\u70b9\u662f\u6ca1\u6709\u771f\u6b63\u7684\u540c\u6b65\u673a\u5236\u3002\n\u5982\u679c\u4efb\u4f55\u4e8b\u4ef6\u5904\u7406\u5668\u65b9\u6cd5\u963b\u585e\u6216\u6267\u884c\u4e00\u4e2a\u8017\u65f6\u8ba1\u7b97\uff0c\u5b83\u4f1a\u963b\u585e\u6240\u6709\u7684\u5904\u7406\u8fdb\u7a0b\u3002\n\u8c03\u7528\u90a3\u4e9b\u5e76\u4e0d\u662f\u4e8b\u4ef6\u9a71\u52a8\u98ce\u683c\u7684\u5e93\u51fd\u6570\u4e5f\u4f1a\u6709\u95ee\u9898\uff0c\u540c\u6837\u8981\u662f\u67d0\u4e9b\u5e93\u51fd\u6570\u8c03\u7528\u4f1a\u963b\u585e\uff0c\u90a3\u4e48\u4e5f\u4f1a\u5bfc\u81f4\u6574\u4e2a\u4e8b\u4ef6\u5faa\u73af\u505c\u6b62\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5bf9\u4e8e\u963b\u585e\u6216\u8017\u65f6\u8ba1\u7b97\u7684\u95ee\u9898\u53ef\u4ee5\u901a\u8fc7\u5c06\u4e8b\u4ef6\u53d1\u9001\u4e2a\u5176\u4ed6\u5355\u72ec\u7684\u73b0\u573a\u6216\u8fdb\u7a0b\u6765\u5904\u7406\u3002\n\u4e0d\u8fc7\uff0c\u5728\u4e8b\u4ef6\u5faa\u73af\u4e2d\u5f15\u5165\u591a\u7ebf\u7a0b\u548c\u591a\u8fdb\u7a0b\u662f\u6bd4\u8f83\u68d8\u624b\u7684\uff0c\n\u4e0b\u9762\u7684\u4f8b\u5b50\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528 concurrent.futures \u6a21\u5757\u6765\u5b9e\u73b0\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "from concurrent.futures import ThreadPoolExecutor\nimport os\n\nclass ThreadPoolHandler(EventHandler):\n    def __init__(self, nworkers):\n        if os.name == 'posix':\n            self.signal_done_sock, self.done_sock = socket.socketpair()\n        else:\n            server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n            server.bind(('127.0.0.1', 0))\n            server.listen(1)\n            self.signal_done_sock = socket.socket(socket.AF_INET,\n                                                  socket.SOCK_STREAM)\n            self.signal_done_sock.connect(server.getsockname())\n            self.done_sock, _ = server.accept()\n            server.close()\n\n        self.pending = []\n        self.pool = ThreadPoolExecutor(nworkers)\n\n    def fileno(self):\n        return self.done_sock.fileno()\n\n    # Callback that executes when the thread is done\n    def _complete(self, callback, r):\n\n        self.pending.append((callback, r.result()))\n        self.signal_done_sock.send(b'x')\n\n    # Run a function in a thread pool\n    def run(self, func, args=(), kwargs={},*,callback):\n        r = self.pool.submit(func, *args, **kwargs)\n        r.add_done_callback(lambda r: self._complete(callback, r))\n\n    def wants_to_receive(self):\n        return True\n\n    # Run callback functions of completed work\n    def handle_receive(self):\n        # Invoke all pending callback functions\n        for callback, result in self.pending:\n            callback(result)\n            self.done_sock.recv(1)\n        self.pending = []"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5728\u4ee3\u7801\u4e2d\uff0crun() \u65b9\u6cd5\u88ab\u7528\u6765\u5c06\u5de5\u4f5c\u63d0\u4ea4\u7ed9\u56de\u8c03\u51fd\u6570\u6c60\uff0c\u5904\u7406\u5b8c\u6210\u540e\u88ab\u6fc0\u53d1\u3002\n\u5b9e\u9645\u5de5\u4f5c\u88ab\u63d0\u4ea4\u7ed9 ThreadPoolExecutor \u5b9e\u4f8b\u3002\n\u4e0d\u8fc7\u4e00\u4e2a\u96be\u70b9\u662f\u534f\u8c03\u8ba1\u7b97\u7ed3\u679c\u548c\u4e8b\u4ef6\u5faa\u73af\uff0c\u4e3a\u4e86\u89e3\u51b3\u5b83\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u5bf9socket\u5e76\u5c06\u5176\u4f5c\u4e3a\u67d0\u79cd\u4fe1\u53f7\u91cf\u673a\u5236\u6765\u4f7f\u7528\u3002\n\u5f53\u7ebf\u7a0b\u6c60\u5b8c\u6210\u5de5\u4f5c\u540e\uff0c\u5b83\u4f1a\u6267\u884c\u7c7b\u4e2d\u7684 _complete() \u65b9\u6cd5\u3002\n\u8fd9\u4e2a\u65b9\u6cd5\u518d\u67d0\u4e2asocket\u4e0a\u5199\u5165\u5b57\u8282\u4e4b\u524d\u4f1a\u8bb2\u6302\u8d77\u7684\u56de\u8c03\u51fd\u6570\u548c\u7ed3\u679c\u653e\u5165\u961f\u5217\u4e2d\u3002\nfileno() \u65b9\u6cd5\u8fd4\u56de\u53e6\u5916\u7684\u90a3\u4e2asocket\u3002\n\u56e0\u6b64\uff0c\u8fd9\u4e2a\u5b57\u8282\u88ab\u5199\u5165\u65f6\uff0c\u5b83\u4f1a\u901a\u77e5\u4e8b\u4ef6\u5faa\u73af\uff0c\n\u7136\u540e handle_receive() \u65b9\u6cd5\u88ab\u6fc0\u6d3b\u5e76\u4e3a\u6240\u6709\u4e4b\u524d\u63d0\u4ea4\u7684\u5de5\u4f5c\u6267\u884c\u56de\u8c03\u51fd\u6570\u3002\n\u5766\u767d\u8bb2\uff0c\u8bf4\u4e86\u8fd9\u4e48\u591a\u8fde\u6211\u81ea\u5df1\u90fd\u6655\u4e86\u3002\n\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u670d\u52a1\u5668\uff0c\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u7ebf\u7a0b\u6c60\u6765\u5b9e\u73b0\u8017\u65f6\u7684\u8ba1\u7b97\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# A really bad Fibonacci implementation\ndef fib(n):\n    if n < 2:\n        return 1\n    else:\n        return fib(n - 1) + fib(n - 2)\n\nclass UDPFibServer(UDPServer):\n    def handle_receive(self):\n        msg, addr = self.sock.recvfrom(128)\n        n = int(msg)\n        pool.run(fib, (n,), callback=lambda r: self.respond(r, addr))\n\n    def respond(self, result, addr):\n        self.sock.sendto(str(result).encode('ascii'), addr)\n\nif __name__ == '__main__':\n    pool = ThreadPoolHandler(16)\n    handlers = [ pool, UDPFibServer(('',16000))]\n    event_loop(handlers)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u8fd0\u884c\u8fd9\u4e2a\u670d\u52a1\u5668\uff0c\u7136\u540e\u8bd5\u7740\u7528\u5176\u5b83Python\u7a0b\u5e8f\u6765\u6d4b\u8bd5\u5b83\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "from socket import *\nsock = socket(AF_INET, SOCK_DGRAM)\nfor x in range(40):\n    sock.sendto(str(x).encode('ascii'), ('localhost', 16000))\n    resp = sock.recvfrom(8192)\n    print(resp[0])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4f60\u5e94\u8be5\u80fd\u5728\u4e0d\u540c\u7a97\u53e3\u4e2d\u91cd\u590d\u7684\u6267\u884c\u8fd9\u4e2a\u7a0b\u5e8f\uff0c\u5e76\u4e14\u4e0d\u4f1a\u5f71\u54cd\u5230\u5176\u4ed6\u7a0b\u5e8f\uff0c\u5c3d\u7ba1\u5f53\u6570\u5b57\u4fbf\u8d8a\u6765\u8d8a\u5927\u65f6\u5019\u5b83\u4f1a\u53d8\u5f97\u8d8a\u6765\u8d8a\u6162\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5df2\u7ecf\u9605\u8bfb\u5b8c\u4e86\u8fd9\u4e00\u5c0f\u8282\uff0c\u90a3\u4e48\u4f60\u5e94\u8be5\u4f7f\u7528\u8fd9\u91cc\u7684\u4ee3\u7801\u5417\uff1f\u4e5f\u8bb8\u4e0d\u4f1a\u3002\u4f60\u5e94\u8be5\u9009\u62e9\u4e00\u4e2a\u53ef\u4ee5\u5b8c\u6210\u540c\u6837\u4efb\u52a1\u7684\u9ad8\u7ea7\u6846\u67b6\u3002\n\u4e0d\u8fc7\uff0c\u5982\u679c\u4f60\u7406\u89e3\u4e86\u57fa\u672c\u539f\u7406\uff0c\u4f60\u5c31\u80fd\u7406\u89e3\u8fd9\u4e9b\u6846\u67b6\u6240\u4f7f\u7528\u7684\u6838\u5fc3\u6280\u672f\u3002\n\u4f5c\u4e3a\u5bf9\u56de\u8c03\u51fd\u6570\u7f16\u7a0b\u7684\u66ff\u4ee3\uff0c\u4e8b\u4ef6\u9a71\u52a8\u7f16\u7801\u6709\u65f6\u5019\u4f1a\u4f7f\u7528\u5230\u534f\u7a0b\uff0c\u53c2\u800312.12\u5c0f\u8282\u7684\u4e00\u4e2a\u4f8b\u5b50\u3002"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.1"
    },
    "toc": {
      "base_numbering": 1,
      "nav_menu": {},
      "number_sections": true,
      "sideBar": true,
      "skip_h1_title": true,
      "title_cell": "Table of Contents",
      "title_sidebar": "Contents",
      "toc_cell": false,
      "toc_position": {},
      "toc_section_display": true,
      "toc_window_display": true
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}